<template>
  <view class="my-settle-container">
    <label class="radio" @click="changeAllState">
      <radio color="#C00000" :checked="isFullCheck" /><text>全选</text>
    </label>
    <!-- 合算区域 -->
    <view class="amount-box">
       合计:<text class="amount">￥{{countPrice}}</text>
    </view>
    <view class="btn-settle" @click="settlement">结算({{checkedCount}})</view>
  </view>
</template>

<script>
  import { mapGetters,mapMutations,mapState } from 'vuex'
  export default {
    name: "my-settle",
    data() {
      return {

      };
    },
    computed:{
      ...mapState('m_user',['token']),
      ...mapGetters('m_cart',['checkedCount','countPrice','total']),
      ...mapGetters('m_user',['addStr']),
      isFullCheck(){
        return this.total === this.checkedCount
      }
    },
    methods:{
      ...mapMutations('m_cart',['updateAllGoodsState']),
      changeAllState(){
       this.updateAllGoodsState(!this.isFullCheck)
      },
      settlement(){
        // 第一个是否选中勾选结算的商品
        if(!this.checkedCount) return uni.$showMsg('还没选中要结算的商品！')
        // 第二判断是否选地址了没
        if(!this.addStr) return uni.$showMsg('还没选择地址！')
        // 第三判断是否登录了没
        if(!this.token) return uni.$showMsg('还没登录，请登录！')
      }
    }
  }

</script>

<style lang="scss">
  .my-settle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 底部固定定位 */
    position: fixed;
    bottom: 0;
    left: 0;
    /* 设置宽高和背景色 */
    width: 100%;
    height: 50px;
    background-color: #fff;
     .radio {
        display: flex;
        align-items: center;
      }
    
      .amount {
        color: #c00000;
      }
    
      .btn-settle {
        height: 50px;
        min-width: 100px;
        background-color: #c00000;
        color: white;
        line-height: 50px;
        text-align: center;
        padding: 0 10px;
      }
  }

</style>

